home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Reference / FAQs on CD / C++ FAQ Lite (2⁄7) < prev    next >
Encoding:
Text File  |  1997-01-17  |  48.7 KB  |  1,149 lines  |  [TEXT/R*ch]

  1. Archive-name: C++-faq/part2
  2. Posting-Frequency: monthly
  3. Last-modified: Jan 1, 1997
  4. URL: http://www.cerfnet.com/~mpcline/c++-faq-lite/
  5.  
  6. AUTHOR: Marshall Cline / cline@parashift.com / Paradigm Shift, Inc. /
  7. One Park St. / Norwood, NY 13668 / 315-353-6100 (voice) / 315-353-6110 (fax)
  8.  
  9. COPYRIGHT: This posting is part of "C++ FAQ Lite."  The entire "C++ FAQ Lite"
  10. document is Copyright(C) 1991-96 Marshall P. Cline, Ph.D., cline@parashift.com.
  11. All rights reserved.  Copying is permitted only under designated situations.
  12. For details, see section [1].
  13.  
  14. NO WARRANTY: THIS WORK IS PROVIDED ON AN "AS IS" BASIS.  THE AUTHOR PROVIDES NO
  15. WARRANTY WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THE WORK, INCLUDING
  16. WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
  17. PURPOSE.
  18.  
  19. C++-FAQ-Lite != C++-FAQ-Book: This document, C++ FAQ Lite, is not the same as
  20. the C++ FAQ Book.  The book (C++ FAQs, Cline and Lomow, Addison-Wesley) is 500%
  21. larger than this document, and is available in bookstores.  For details, see
  22. section [3].
  23.  
  24. ==============================================================================
  25.  
  26. SECTION [4]: Recent changes to this document
  27.  
  28.  
  29. [4.1] What updates were made for the 01/97 release? [NEW!]
  30.  
  31. [Recently created (on 1/97).]
  32.  
  33. Global changes:
  34.  * Added the (much requested!) one-click download feature[2.2].  This
  35.    automagically sends you a copy of the entire FAQ so you can browse off-line.
  36.    There's a similar feature to get a copy of the "plaintext" version of the
  37.    FAQ[2.3].
  38.  * Removed those pesky "hit counters" from each HTML page.
  39.  * Added nifty forward and backward links just after each FAQ.
  40.  * Added more nifty navigation aids at the bottom of each page.
  41.  * Renamed section [6] from "Management Issues" to "Big Picture Issues."
  42.  
  43. New FAQs:
  44.  * [4.1] What updates were made for the 01/97 release?
  45.  * [15.2] Why does my program go into an infinite loop when someone enters an
  46.    invalid input character?
  47.  * [15.3] How does that funky while (cin >> foo) syntax work?
  48.  * [16.16] But the previous FAQ's code is SOOOO tricky and error prone! Isn't
  49.    there a simpler way?
  50.  * [25.4] Is the ?: operator evil since it can be used to create unreadable
  51.    code?
  52.  
  53. Changed FAQs:
  54.  * [1.3] Copying Permissions
  55.    (simplified)
  56.  * [2.1] Where's the closest mirror site to access this document?
  57.    (removed the "USA-2" site)
  58.  * [2.2] How can I get a Copy of all the HTML files of C++ FAQ Lite so I can
  59.    read them Off-Line?
  60.    (rewrote and added a one-click feature to get .zip, .tar.Z or .tar.gz
  61. format)
  62.  * [2.3] How can I get a Copy of all the "plaintext" files of C++ FAQ Lite so I
  63.    can read them Off-Line?
  64.    (rewrote and added a one-click feature to get .zip, .tar.Z or .tar.gz
  65. format)
  66.  * [5.1] What does IMHO mean? (or IMO, IMNSHO, FWIW, OTOH, etc.)?
  67.    (added KUTGW (thanks to Bengt Richter))
  68.  * [15.6] How can I provide printing for my class Fred?
  69.    (added note about cascading operator<< calls)
  70.  * [15.7] How can I provide input for my class Fred?
  71.    (added note about cascading operator<< calls)
  72.  * [16.6] How can I convince my (older) compiler to automatically check new to
  73.    see if it returns NULL?
  74.    (fixed bugs: new handlers don't take arguments, thanks to Scott Aaron;
  75. changed set_new_hanlder to set_new_handler, thanks to Peter Andersson)
  76.  * [16.15] How do I allocate multidimensional arrays using new?
  77.    (rewritten and expanded with a rectangular-matrix case)
  78.  * [18.1] What is "const correctness"?
  79.    (rewrote because of helpful feedback from Nor Jaidi)
  80.  * [21.6] Is a Circle a kind-of an Ellipse?
  81.    (added a caveat that setSize(x,y) isn't sacred)
  82.  * [21.7] Are there other options to the "Circle is/isnot kind-of Ellipse"
  83.    dilemma?
  84.    (added a caveat that setSize(x,y) isn't sacred)
  85.  * [21.8] But I have a Ph.D. in Mathematics, and I'm sure a Circle is a kind of
  86.    an Ellipse! Does this mean Marshall Cline is stupid? Or that C++ is stupid?
  87.    Or that OO is stupid?
  88.    (added a caveat that setSize(x,y) isn't sacred)
  89.  * [23.1] When my base class's constructor calls a virtual function, why
  90.    doesn't my derived class's override of that virtual function get invoked?
  91.    (rewrote)
  92.  * [29.8] How can I pass an object of a C++ class to/from a C function?
  93.    (added #ifndef FRED_H / #define FRED_H to code)
  94.  * [33.3] Where can I get information about the C++ compiler from {Borland,
  95.    IBM, Microsoft, Semantic, Sun, etc.}?
  96.    (added HP C++)
  97.  * [35.4] Where can I get OS-specific questions answered (e.g., BC++, DOS,
  98.    Windows, etc)?
  99.    (added Borland C++ URLs thanks to Simon Edlund)
  100.  
  101. ==============================================================================
  102.  
  103. [4.2] What updates were made for the 11/96 release? [NEW!]
  104.  
  105. [Recently created (on 11/96).]
  106.  
  107. New FAQs:
  108.  * [2.2] How can I get a Copy of all the HTML files of C++ FAQ Lite so I can
  109.    read them Off-Line?
  110.  * [4.2] What updates were made for the 11/96 release?
  111.  * [20.3] What's the difference between how virtual and non-virtual member
  112.    functions are called?
  113.  * [33.1] How do I display text in the status bar using MFC?
  114.    (with the help of Paul Ganney)
  115.  
  116. Changed FAQs:
  117.  * [8.4] How can you reseat a reference to make it refer to a different object?
  118.    (changed last line from "pointer to const" to "const pointer" thanks to
  119. Neelesh Pandit)
  120.  * [25.10] Are there any other sources of coding standards?
  121.    (rewrote and added more URLs)
  122.  * [33.6] If name mangling was standardized, could I link code compiled with
  123.    compilers from different compiler vendors?
  124.    (reworded and added v-table and v-pointer references[20.3])
  125.  
  126. ==============================================================================
  127.  
  128. [4.3] What updates were made for the 10/96 release?
  129.  
  130. New FAQs:
  131.  * [4.3] What updates were made for the 10/96 release?
  132.  
  133. Changed FAQs:
  134.  * [5.8] Which newsgroup should I post my questions?
  135.    (added comp.sys.mac.programmer.* and comp.sys.mac.oop.*)
  136.  * [16.6] How can I convince my (older) compiler to automatically check new to
  137.    see if it returns NULL?
  138.    (added comments on constructors of globals; thanks to William Carroll
  139. carrolw@ttc.com)
  140.  * [25.10] Are there any other sources of coding standards?
  141.    (added URLs)
  142.  * [33.3] Where can I get information about the C++ compiler from {Borland,
  143.    IBM, Microsoft, Semantic, Sun, etc.}?
  144.    (added URL for Metrowerks and Watcom compilers)
  145.  
  146. ==============================================================================
  147.  
  148. [4.4] What updates were made for the 09/96 release?
  149.  
  150. New FAQs:
  151.  * [4.4] What updates were made for the 09/96 release?
  152.  * [5.1] What does IMHO mean? (or IMO, IMNSHO, FWIW, OTOH, etc.)?
  153.  * [5.2] How do I get comp.lang.c++ to do my homework problem for me?
  154.  * [5.3] What should I do if I see someone else posting a homework problem?
  155.    (with the help of Phil Staite pstaite@vnet.ibm.com)
  156.  * [18.4] What does "const Fred* p" mean?
  157.  * [18.5] What's the difference between "const Fred* p", "Fred* const p" and
  158.    "const Fred* const p"?
  159.  * [18.6] What does "const Fred& x" mean?
  160.  * [18.7] Does "Fred& const x" make any sense?
  161.  * [18.8] What does "Fred const& x" mean?
  162.  * [18.13] Does "const Fred* p" mean that *p can't change?
  163.  * [25.10] Are there any other sources of coding standards?
  164.  * [33.2] How can I decompile an executable program back into C++ source code?
  165.    (with the help of Phil Staite pstaite@vnet.ibm.com)
  166.  
  167. Changed FAQs:
  168.  * [8.4] How can you reseat a reference to make it refer to a different object?
  169.    (added a cross reference regarding pointer to const[18.4])
  170.  * [9.4] How do you tell the compiler to make a non-member function inline?
  171.    (strengthened the "Note:" at the end)
  172.  * [16.18] How can I force objects of my class to always be created via new
  173.    rather than as locals or global/static objects?
  174.    (reworded and added a paragraph on using friend[14] to soften the original
  175. goal)
  176.  * [16.20] How do I provide reference counting with copy-on-write semantics?
  177.    (added links to the self assignment[12.1] discussion)
  178.  * [16.21] How do I provide reference counting with copy-on-write semantics for
  179.    a hierarchy of classes?
  180.    (added links to the self assignment[12.1] discussion)
  181.  * [17.2] How should I handle resources if my constructors may throw
  182.    exceptions?
  183.    (added cross-references for reference-counted[16.19] and remote[13.3]
  184. smart-pointers)
  185.  * [21.2] Derived* --> Base* works OK; why doesn't Derived** --> Base** work?
  186.    (fixed a bug with help from William Wu)
  187.  * [22.4] What is a "pure virtual" member function?
  188.    (reworded)
  189.  * [32.3] Where can I get help on how to use STL?
  190.    (fixed the URL for Kenny Zalewski's STL guide)
  191.  * [33.3] Where can I get information about the C++ compiler from {Borland,
  192.    IBM, Microsoft, Semantic, Sun, etc.}?
  193.    (added URLs for Silicon Graphics and Symantec compilers)
  194.  * [35.2] Are there any pretty-printers that reformat C++ source code?
  195.    (added a URL for "V Communications")
  196.  
  197. ==============================================================================
  198.  
  199. [4.5] What updates were made for the 08/96 release?
  200.  
  201. Global changes:
  202.  * Recently added/changed FAQs are now chained together using hyper-links
  203.    (mainly for those who want to find out what has changed since the last time
  204.    they read this document; only available in the HTML version)
  205.  * Recently added FAQs are now decorated with [NEW!] ("recently" = "in the
  206.    current or previous release")
  207.  * Recently changed FAQs are now decorated with [UPDATED!] ("recently" = "in
  208.    the current or previous release")
  209.  * The look-and-feel of hyper-linked cross references is changed (NOTE: this
  210.    change ONLY shows up in the HTML version)
  211.    - The old look-and-feel "looks like this[4.5]"
  212.    - The new look-and-feel "looks like this[4.5]"
  213.  * Added section [12] Assignment operators
  214.  * Added section [26] Learning OO/C++
  215.  
  216. New FAQs:
  217.  * [4.5] What updates were made for the 08/96 release?
  218.  * [7.3] When is an interface "good"?
  219.  * [7.4] What is encapsulation?
  220.  * [7.5] How does C++ help with the tradeoff of safety vs. usability?
  221.  * [9.2] How can inline functions help with the tradeoff of safety vs. speed?
  222.  * [12.1] What is "self assignment"?
  223.  * [12.2] Why should I worry about "self assignment"?
  224.  * [12.3] OK, OK, already; I'll handle self-assignment.  How do I do it?
  225.  * [13.3] What are some examples of operator overloading?
  226.  * [15.10] Why can't I open a file in a different directory such as
  227.    "..\test.dat"?
  228.  * [26.1] What is mentoring?
  229.  * [26.2] Should I learn C before I learn OO/C++?
  230.  * [26.3] Should I learn Smalltalk before I learn OO/C++?
  231.  * [26.4] Should I buy one book, or several?
  232.  * [26.5] What are some best-of-breed C++ morality guides?
  233.  * [26.6] What are some best-of-breed C++ legality guides?
  234.  * [26.7] Are there other OO books that are relevant to OO/C++?
  235.  * [33.3] Where can I get information about the C++ compiler from {Borland,
  236.    IBM, Microsoft, Semantic, Sun, etc.}?
  237.  
  238. Changed FAQs:
  239.  * [6.4] Is C++ better than Ada? (or Visual Basic, C, FORTRAN, Pascal,
  240.    Smalltalk, or any other language?)
  241.    (reworded the last paragraph)
  242.  * [6.6] How long does it take to learn OO/C++?
  243.    (added management-level hints for training developers in OO/C++)
  244.  * [9.3] Why should I use inline functions? Why not just use plain old #define
  245.    macros?
  246.    (moved)
  247.  * [13.4] But operator overloading makes my class look ugly; isn't it supposed
  248.    to make my code clearer?
  249.    (rewritten)
  250.  * [13.8] How do I create a subscript operator for a Matrix class?
  251.    (fixed a bug: "double** data_" is now "double* data_")
  252.  * [25.8] Are there any lint-like guidelines for C++?
  253.    (added links to the self assignment[12.1] discussion)
  254.  * [26.6] What are some best-of-breed C++ legality guides?
  255.    (fixed the ISBN for Stan Lippman's book)
  256.  * [27.1] What's the difference between C++ and Smalltalk?
  257.    (rewritten)
  258.  * [32.4] How can you tell if you have a dynamically typed C++ class library?
  259.    (moved from the section on Smalltalk[27])
  260.  * [32.5] What is the NIHCL? Where can I get it?
  261.    (moved from the section on Smalltalk[27])
  262.  * [32.8] Where can I get tons and tons of more information on C++ class
  263.    libraries?
  264.    (updated the URL)
  265.  * [34.1] Why can't the compiler find my header file in
  266.    #include "c:\test.hpp" ?
  267.    (updated to refer to [15.10])
  268.  
  269. ==============================================================================
  270.  
  271. [4.6] What updates were made for the 07/96 release?
  272.  
  273. Global changes:
  274.  * Created an extensive subject index
  275.  * Added hyper-linked internal cross references throughout (mainly useful for
  276.    the HTML version)
  277.  * Changed the name of the document from On-Line C++ FAQs to C++ FAQs Lite
  278.  * Created section [23] Inheritance -- what your mother never told you
  279.  * Split sections [10] Constructors and [11] Destructors into two distinct
  280.    sections
  281.  * Major reorganization of sections [19] Inheritance -- basics, [20]
  282.    Inheritance -- virtual functions, [21] Inheritance -- proper inheritance and
  283.    substitutability, and [22] Inheritance -- abstract base classes (ABCs)
  284.  * Added example code throughout section [29] How to mix C and C++
  285.  
  286. New FAQs:
  287.  * [4.6] What updates were made for the 07/96 release?
  288.  * [5.5] What do I do if someone else posts a question that's already in the
  289.    FAQ?
  290.  * [5.6] What makes a good Subject: line?
  291.  * [6.8] Are virtual functions (dynamic binding) central to OO/C++?
  292.  * [6.9] I'm from Missouri.  Can you give me a simple reason why virtual
  293.    functions (dynamic binding) make a big difference?
  294.  * [7.6] How can I prevent other programmers from violating encapsulation by
  295.    seeing the private parts of my class?
  296.  * [7.7] Is Encapsulation a Security device?
  297.  * [10.4] Is the default constructor for Fred always Fred::Fred()?
  298.  * [10.5] Which constructor gets called when I create an array of Fred objects?
  299.  * [10.6] What is the "Named Constructor Idiom"?
  300.  * [10.7] Why can't I initialize my static member data in my constructor's
  301.    initialization list?
  302.  * [11.2] What's the order that local objects are destructed?
  303.  * [11.3] What's the order that objects in an array are destructed?
  304.  * [11.4] Can I overload the destructor for my class?
  305.  * [11.5] Should I explicitly call a destructor on a local variable?
  306.  * [11.6] What if I want a local to "die" before the close } of the scope in
  307.    which it was created? Can I call a destructor on a local if I really want
  308.    to?
  309.  * [11.7] OK, OK already; I won't explicitly call the destructor of a local;
  310.    but how do I handle the above situation?
  311.  * [11.8] What if I can't wrap the local in an artificial block?
  312.  * [11.9] But can I explicitly call a destructor if I've allocated my object
  313.    with new?
  314.  * [11.10] What is "placement new" and why would I use it?
  315.  * [11.11] When I write a destructor, do I need to explicitly call the
  316.    destructors for my member objects?
  317.  * [13.6] Can I overload operator== so it lets me compare two char[] using a
  318.    string comparison?
  319.  * [13.8] How do I create a subscript operator for a Matrix class?
  320.  * [13.9] Should I design my classes from the outside (interfaces first) or
  321.    from the inside (data first)?
  322.  * [15.7] How can I provide input for my class Fred?
  323.  * [16.5] Do I need to check for NULL after p = new Fred()?
  324.  * [16.6] How can I convince my (older) compiler to automatically check new to
  325.    see if it returns NULL?
  326.  * [16.7] Do I need to check for NULL before delete p?
  327.  * [16.8] What are the two steps that happen when I say delete p?
  328.  * [16.9] In p = new Fred(), does the Fred memory "leak" if the Fred
  329.    constructor throws an exception?
  330.  * [16.12] Can I drop the [] when deleteing array of some built-in type (char,
  331.    int, etc)?
  332.  * [16.13] After p = new Fred[n], how does the compiler know there are n
  333.    objects to be destructed during delete[] p?
  334.  * [16.19] How do I do simple reference counting?
  335.  * [16.20] How do I provide reference counting with copy-on-write semantics?
  336.  * [16.21] How do I provide reference counting with copy-on-write semantics for
  337.    a hierarchy of classes?
  338.  * [17.3] How do I change the string-length of an array of char to prevent
  339.    memory leaks even if/when someone throws an exception?
  340.  * [18.12] Why does the compiler allow me to change an int after I've pointed
  341.    at it with a const int*?
  342.  * [22.5] How do you define a copy constructor or assignment operator for a
  343.    class that contains a pointer to a (abstract) base class?
  344.  * [23.4] What does it mean that the "virtual table" is an unresolved external?
  345.  * [25.9] Which is better: identifier names that_look_like_this or identifier
  346.    names thatLookLikeThis?
  347.    (with the help of James Robinson james-robinson@uiowa.edu)
  348.  * [29.1] What do I need to know when mixing C and C++ code?
  349.  * [30.5] How can I avoid syntax errors when calling a member function using a
  350.    pointer-to-member-function?
  351.  * [31.1] How can I make a perl-like associative array in C++?
  352.  * [32.2] How can I find a Fred object in an STL container of Fred* such as
  353.    vector<Fred*>?
  354.  * [32.8] Where can I get tons and tons of more information on C++ class
  355.    libraries?
  356.  * [33.4] How do compilers use "over-allocation" to remember the number of
  357.    elements in an allocated array?
  358.  * [33.5] How do compilers use an "associative array" to remember the number of
  359.    elements in an allocated array?
  360.  * [34.1] Why can't the compiler find my header file in
  361.    #include "c:\test.hpp" ?
  362.  * [34.2] Does C++ have new scoping rules for for loops?
  363.  
  364. Changed FAQs:
  365.  * [5.4] How can I find out about general netiquette so I don't embarrass
  366.    myself?
  367.    (rewritten)
  368.  * [5.7] How do I post a question about code that doesn't work correctly?
  369.    (rewritten)
  370.  * [7.8] What's the difference between the keywords struct and class?
  371.    (rewritten)
  372.  * [10.8] Why are classes with static data members getting linker errors?
  373.    (rewritten)
  374.  * [11.12] When I write a derived class's destructor, do I need to explicitly
  375.    call the destructor for my base class?
  376.    (added example code to illustrate the compiler's automagic calls to
  377. destructors of member objects and base class subobjects)
  378.  * [15.6] How can I provide printing for my class Fred?
  379.    (added example code to illustrate operator<< on an ostream)
  380.  * [15.8] How can I provide printing for an entire hierarchy of classes?
  381.    (moved from the section on Abstraction[22])
  382.  * [16.18] How can I force objects of my class to always be created via new
  383.    rather than as locals or global/static objects?
  384.    (added a reference to the Named Constructor Idiom[10.6])
  385.  * [29.2] How can I include a standard C header file in my C++ code?
  386.    (rewritten)
  387.  * [29.3] How can I include a non-system C header file in my C++ code?
  388.    (rewritten)
  389.  * [29.4] How can I modify my own C header files so it's easier to #include
  390.    them in C++ code?
  391.    (rewritten)
  392.  * [33.8] Is there a yacc-able C++ grammar?
  393.    (updated the URL for the yacc-able C++ grammar)
  394.  * [35.2] Are there any pretty-printers that reformat C++ source code?
  395.    (added "C-Clearly" and GNU indent to the list of pretty-printers)
  396.  
  397. ==============================================================================
  398.  
  399. [4.7] What updates were made for the 06/96 release?
  400.  
  401. New FAQs:
  402.  * [4.7] What updates were made for the 06/96 release?
  403.  * [10.2] Is there any difference between List x; and List x();?
  404.  * [34.5] Why is floating point so inaccurate? Why doesn't this print 0.43?
  405.    (with the help of Phil Staite pstaite@vnet.ibm.com)
  406.  
  407. Changed FAQs:
  408.  * [2.1] Where's the closest mirror site to access this document?
  409.    (added Finland mirror site: http://www.utu.fi/~sisasa/oasis/cppfaq/)
  410.  * [3.2] Is this on-line ("Lite") document the same as the C++ FAQ Book?
  411.    (fixed URL of book at Addison-Wesley)
  412.  * [3.3] How can I download a free copy of the C++ FAQ Book?
  413.    (fixed URL of book at Addison-Wesley)
  414.  * [18.1] What is "const correctness"?
  415.    (added info on what happens when you try to pass a const parameter to a
  416. non-const function)
  417.  * [20.4] When should my destructor be virtual?
  418.    (added the nitty-gritty rule for when you need to have a virtual destructor)
  419.  * [21.4] Is an array of Derived a kind-of array of Base?
  420.    (fixed bug in code)
  421.  * [22.3] What is an ABC?
  422.    (reworded)
  423.  * [22.4] What is a "pure virtual" member function?
  424.    (reworded)
  425.  * [28.4] Should I normally use pointers to freestore allocated objects for my
  426.    data members, or should I use "composition"?
  427.    (reworded)
  428.  * [29.8] How can I pass an object of a C++ class to/from a C function?
  429.    (fixed a bug in the code)
  430.  * [31.4] What's the idea behind templates?
  431.    (reworded)
  432.  * [31.6] What's the syntax / semantics for a "class template"?
  433.    (reworded)
  434.  * [35.1] Is there a TeX or LaTeX macro that fixes the spacing on "C++"?
  435.    (added a new LaTeX macro)
  436.  * [35.2] Are there any pretty-printers that reformat C++ source code?
  437.    (fixed URL of C++2LaTeX)
  438.  
  439. ==============================================================================
  440.  
  441. [4.8] What updates were made for the 05/96 release?
  442.  
  443. Updated everything.  Transformed the source from raw text to HTML.
  444. Reorganized, reworded, expanded, added example code, etc, etc.
  445.  
  446. ==============================================================================
  447.  
  448. [4.9] What updates were made for the 04/96 release?
  449.  
  450. New FAQs:
  451.  * [4.9] What updates were made for the 04/96 release?
  452.  * [29.2] How can I include a standard C header file in my C++ code?
  453.  * [29.3] How can I include a non-system C header file in my C++ code?
  454.  * [29.4] How can I modify my own C header files so it's easier to #include
  455.    them in C++ code?
  456.  
  457. Changed FAQs:
  458.  * [2.1] Where's the closest mirror site to access this document?
  459.    (added European mirror site:
  460. http://www.informatik.uni-konstanz.de/~kuehl/cpp/cppfaq.htm)
  461.  * [16.14] Is it legal (and moral) for a member function to say delete this?
  462.    (rewritten)
  463.  * [22.4] What is a "pure virtual" member function?
  464.    (rewritten)
  465.  
  466. ==============================================================================
  467.  
  468. [4.10] What updates were made for the 03/96 release?
  469.  
  470. New FAQs:
  471.  * [4.10] What updates were made for the 03/96 release?
  472.  * [6.4] Is C++ better than Ada? (or Visual Basic, C, FORTRAN, Pascal,
  473.    Smalltalk, or any other language?)
  474.  * [31.2] How can I build a <favorite container> of objects of different types?
  475.    (with the help of Phil Staite pstaite@vnet.ibm.com)
  476.  
  477. Changed FAQs:
  478.  * [2.3] How can I get a Copy of all the "plaintext" files of C++ FAQ Lite so I
  479.    can read them Off-Line?
  480.    (added URL ftp://rtfm.mit.edu/pub/usenet-by-group/comp.lang.c++/)
  481.  * [6.12] Where can I get a copy of the latest ANSI/ISO-C++ draft standard?
  482.    (fixed the URL for the ANSI/ISO-C++ Committee Draft)
  483.  * [15.1] Why should I use <iostream.h> instead of the traditional <stdio.h>?
  484.    (reworded)
  485.  * [16.2] Can I free() pointers allocated with new? Can I delete pointers
  486.    allocated with malloc()?
  487.    (added an admonition not to mix new and free() or malloc() and delete)
  488.  * [25.1] What are some good C++ coding standards?
  489.    (reworded)
  490.  * [25.2] Are coding standards necessary? Are they sufficient?
  491.    (reworded)
  492.  * [25.3] Should our organization determine coding standards from our C
  493.    experience?
  494.    (reworded)
  495.  * [25.8] Are there any lint-like guidelines for C++?
  496.    (reworded)
  497.  * [27.3] Which is a better fit for C++: "static typing" or "dynamic typing"?
  498.    (updated info on dynamic_cast and typeid())
  499.  * [35.2] Are there any pretty-printers that reformat C++ source code?
  500.    (fixed URL of C++2LaTeX)
  501.  
  502. ==============================================================================
  503.  
  504. [4.11] What updates were made for the 09/95 release?
  505.  
  506. New FAQs:
  507.  * [4.11] What updates were made for the 09/95 release?
  508.  * [15.9] How can I "reopen" cin and cout in binary mode under DOS and/or OS/2?
  509.  * [32.3] Where can I get help on how to use STL?
  510.  * [32.6] Where can I ftp the code that accompanies "Numerical Recipes"?
  511.  * [32.7] Why is my executable so large?
  512.  
  513. Changed FAQs:
  514.  * [6.12] Where can I get a copy of the latest ANSI/ISO-C++ draft standard?
  515.    (added info on FTP access for the ANSI/ISO-C++ Committee Draft)
  516.  * [8.3] What happens if you return a reference?
  517.    (fixed a bug (variable i was not declared))
  518.  * [16.15] How do I allocate multidimensional arrays using new?
  519.    (reworded)
  520.  * [32.1] Where can I get a copy of "STL"?
  521.    (reworded)
  522.  
  523. ==============================================================================
  524.  
  525. [4.12] What updates were made for the 06/95 release?
  526.  
  527. New FAQs:
  528.  * [4.12] What updates were made for the 06/95 release?
  529.  * [16.15] How do I allocate multidimensional arrays using new?
  530.    (with the help of Doug Shapter)
  531.  * [30.3] Why do I keep getting compile errors (type mismatch) when I try to
  532.    use a member function as an interrupt service routine?
  533.  
  534. Changed FAQs:
  535.  * [6.12] Where can I get a copy of the latest ANSI/ISO-C++ draft standard?
  536.    (fixed the US-Mail access for the ANSI/ISO-C++ Committee Draft)
  537.  * [16.18] How can I force objects of my class to always be created via new
  538.    rather than as locals or global/static objects?
  539.    (rewritten)
  540.  
  541. ==============================================================================
  542.  
  543. [4.13] What updates were made for the 04/95 release?
  544.  
  545. New FAQs:
  546.  * [4.13] What updates were made for the 04/95 release?
  547.  * [35.4] Where can I get OS-specific questions answered (e.g., BC++, DOS,
  548.    Windows, etc)?
  549.  
  550. Changed FAQs:
  551.  * [32.5] What is the NIHCL? Where can I get it?
  552.    (fixed the FTP address)
  553.  
  554. ==============================================================================
  555.  
  556. [4.14] What updates were made for the 03/95 release?
  557.  
  558. New FAQs:
  559.  * [4.14] What updates were made for the 03/95 release?
  560.  * [15.4] Why does my input seem to process past the end of file?
  561.  * [15.5] Why is my program ignoring my input request after the first
  562.    iteration?
  563.  * [16.14] Is it legal (and moral) for a member function to say delete this?
  564.  
  565. Changed FAQs:
  566.  * [35.3] Is there a C++-mode for GNU emacs? If so, where can I get it?
  567.    (updated the information on cc-mode.el)
  568.  
  569. ==============================================================================
  570.  
  571. [4.15] What updates were made for the 01/95 release?
  572.  
  573. New FAQs:
  574.  * [2.4] Where can I download a Chinese translation of this on-line document?
  575.  * [4.15] What updates were made for the 01/95 release?
  576.  
  577. ==============================================================================
  578.  
  579. [4.16] What updates were made for the 12/94 release?
  580.  
  581. New FAQs:
  582.  * [4.16] What updates were made for the 12/94 release?
  583.  * [32.1] Where can I get a copy of "STL"?
  584.  * [33.6] If name mangling was standardized, could I link code compiled with
  585.    compilers from different compiler vendors?
  586.  
  587. Changed FAQs:
  588.  * [24.3] Which should I prefer: composition or private inheritance?
  589.    (reworded)
  590.  
  591. ==============================================================================
  592.  
  593. [4.17] What updates were made for the 11/94 release?
  594.  
  595. New FAQs:
  596.  * [3.1] Is there a C++ FAQ Book I can buy in a bookstore?
  597.  * [3.2] Is this on-line ("Lite") document the same as the C++ FAQ Book?
  598.  * [3.3] How can I download a free copy of the C++ FAQ Book?
  599.  * [3.4] Why would I spend good money on a book when I can download it for
  600.    free?
  601.  * [4.17] What updates were made for the 11/94 release?
  602.  
  603. ==============================================================================
  604.  
  605. [4.18] What updates were made for the 08/94 release?
  606.  
  607. Rewrote most of the answers to provide general cleanup.  Changed the quotation
  608. marks to "..." rather than `...' and/or ``...''.  Sample code lines now start
  609. with a tab (no other lines starts with a tab).  Everything was edited; minor
  610. modifications everywhere.
  611.  
  612. New FAQs:
  613.  * [4.18] What updates were made for the 08/94 release?
  614.  * [18.10] What do I do if I want to update an "invisible" data member inside a
  615.    const member function?
  616.  * [27.3] Which is a better fit for C++: "static typing" or "dynamic typing"?
  617.  
  618. ==============================================================================
  619.  
  620. [4.19] What updates were made before 08/94?
  621.  
  622. This document was originally written in 1991.  I have no record of the specific
  623. changes that were made until 8/94.
  624.  
  625. ==============================================================================
  626.  
  627. SECTION [5]: Netiquette when posting to comp.lang.c++
  628.  
  629.  
  630. [5.1] What does IMHO mean? (or IMO, IMNSHO, FWIW, OTOH, etc.)? [UPDATED!]
  631.  
  632. [Recently added KUTGW (thanks to Bengt Richter) (on 1/97).]
  633.  
  634. Here's a partial list of acronyms in alphabetical order:
  635.  * BTW = By the way
  636.  * FWIW = For what it's worth
  637.  * FYI = For your information
  638.  * IMHO = In my humble opinion (egoless)
  639.  * IMNSHO = In my not-so humble opinion (a lot of ego)
  640.  * IMO = In my opinion (a little ego)
  641.  * KUTGW = Keep Up The Good Work
  642.  * MYOB = Mind your own business
  643.  * OTOH = On the other hand
  644.  * RTFM = Read the ___ manual
  645.  * SO = Significant other (as in, "My SO and I went for a walk...")
  646.  
  647. ==============================================================================
  648.  
  649. [5.2] How do I get comp.lang.c++ to do my homework problem for me?
  650.  
  651. Shame on you!
  652.  
  653. Please do not post your homework questions to comp.lang.c++.
  654.  
  655. ==============================================================================
  656.  
  657. [5.3] What should I do if I see someone else posting a homework problem?
  658.  
  659. When a slackard[5.2] asks comp.lang.c++ to do their homework for them,
  660. answering their question is the worst thing for them.  Please don't do it!
  661. Instead you can use the following table of "frequently asked homework
  662. assignments" to give them a hint/pointer:
  663.  
  664. ===TABLE-BEGIN=== (yea, I know; it's pathetic; the HTML version is better)
  665.  
  666. ===TABLE-ROW===
  667. If someone asks...
  668. ---
  669. ...then here's a brief answer:
  670.  
  671. ===TABLE-ROW===
  672. How do I do Equation Parsing in C++?
  673. ---
  674. Use a stack of operators to convert infix to postfix, then a stack of operands
  675. to evaluate the postfix expression.
  676.  
  677. ===TABLE-ROW===
  678. How do I do Shortest Path in C++?
  679. ---
  680. Look up Dijkstra's algorithm and backtracking.
  681.  
  682. ===TABLE-ROW===
  683. How do I do Sorting in C++?
  684. ---
  685. Look up heapsort, quicksort, merge sort, internal and external sorting.
  686.  
  687. ===TABLE-ROW===
  688. How do I do Minimum Spanning Trees in C++?
  689. ---
  690. Look up Kruskal and/or Prim's algorithm.
  691.  
  692. ===TABLE-ROW===
  693. How do I do Combinations and/or Permutations in C++?
  694. ---
  695. See your algorithms book.
  696.  
  697. ===TABLE-ROW===
  698. How do I do <some small essay problem; obviously contrived for a school
  699. assignment; too well defined to to be from the real world> in C++?
  700. ---
  701. Do it yourself. If you get stuck, ask a specific question.
  702.  
  703. ===TABLE-END===
  704.  
  705. [If anyone has other suggestions that should go into this table, please let me
  706. know; thanks; (cline@parashift.com)].
  707.  
  708. ==============================================================================
  709.  
  710. [5.4] How can I find out about general netiquette so I don't embarrass myself?
  711.  
  712. Key guidelines:
  713.  * Do not say, "Please respond by e-mail because I don't normally read this
  714.    newsgroup".  If you don't have enough time for the newsgroup, don't expect
  715.    the newsgroup to have enough time for you.
  716.  * Do not post questions that are answered in the newsgroup's FAQ.  That's like
  717.    saying your time (to read the FAQ) is more valuable than the time of
  718.    hundreds and hundreds of others (to answer your question).  Tres uncool.
  719.    Read the FAQ first![5.5]
  720.  * Do not cross post your question to a big pile of newsgroups.  Post to the
  721.    newsgroup (singular) that best fits your question[5.8].  If you don't get an
  722.    answer in the "right" newsgroup, post somewhere else but redirect followups
  723.    back to the "right" newsgroup.
  724.  * Do include a working e-mail address in your signature.  If your From:
  725.    address is not correct, please notify your system administrator.  Until it's
  726.    fixed, add a Reply-to: line that gives your correct e-mail address.
  727.  
  728. Many more general netiquette questions are answered in the newsgroup
  729. news.announce.newusers.  This newsgroup contains many must-read articles for
  730. new users.
  731.  
  732. ==============================================================================
  733.  
  734. [5.5] What do I do if someone else posts a question that's already in the FAQ?
  735.  
  736. Please don't answer a question that's already in the FAQ.  Instead politely but
  737. firmly point the questioner to the FAQ using the following template:
  738.  
  739.     Subject: It's in the FAQ (was: Original_Subject_Goes_Here)
  740.  
  741.     > Original_Question_Goes_Here [...]
  742.  
  743.     This issue is covered in the C++ FAQ.
  744.     You can get the FAQ at:
  745.         http://www.cerfnet.com/~mpcline/c++-faq-lite/
  746.  
  747.     Please read the FAQ.
  748.  
  749. If you're willing to help in this effort, consider yourself "deputized" to
  750. point people to the FAQ using something like the above template.  With your
  751. help, hopefully we can improve the signal-to-noise ratio on comp.lang.c++ and
  752. thereby preserve it as a valuable resource.
  753.  
  754. Note #1: Please don't give them the location of the appropriate FAQ.  E.g.,
  755. don't say, "Look at FAQ [10.3]" or "Look in section [10]".  It's the old
  756. give-them-a-fish vs. teach-them-to-fish problem.
  757.  
  758. Note #2: Please be polite.  I'm hoping we can avoid "RTFM" or "RTFFAQ"
  759. euphemisms (or worse!).
  760.  
  761. Thanks for any help you can give in this matter.
  762.  
  763. ==============================================================================
  764.  
  765. [5.6] What makes a good Subject: line?
  766.  
  767. Be descriptive:
  768.  * Bad: "Subject: HELP"
  769.  * Bad: "Subject: C++ problem"
  770.  * Bad: "Subject: SEX SEX SEX"
  771.  * Good: "Subject: Problem new'ing a multi-dimensional array"
  772.  
  773. Mention your compiler/version if you think it's relevant.
  774.  
  775. ==============================================================================
  776.  
  777. [5.7] How do I post a question about code that doesn't work correctly?
  778.  
  779. Key guidelines:
  780.  
  781.  1. Post compile'able code: avoid ellipses, such as void f() { ... }
  782.  
  783.  2. Post complete code: put in all necessary #includes and declarations of
  784.     needed types and functions
  785.  
  786.  3. Post minimal code: just enough to demonstrate the problem; skip I/O and
  787.     calls to libraries if possible
  788.  
  789.  4. Post one compilation unit: if possible, combine Foo.h into Foo.cpp
  790.  
  791.  5. Post the tools you used: compiler name, version number, operating system,
  792.     etc
  793.  
  794.  6. Post the tool options you used: libraries, exact compiler and linker
  795.     options, etc
  796.  
  797.  7. Post the exact messages you received; differentiate between compiler,
  798.     linker, and runtime messages
  799.  
  800. As always, make sure your question isn't already in the FAQ.  Use the subject
  801. index to check.
  802.  
  803. ==============================================================================
  804.  
  805. [5.8] Which newsgroup should I post my questions?
  806.  
  807. Only post to comp.lang.c++ if your question is about the C++ language itself.
  808. For example, C++ code design, syntax, style, rules, bugs, etc.
  809. Operating-specific questions (e.g., about Windows NT / 95 / 3.x, UNIX, etc.)
  810. should go to an operating-system-specific newsgroup (see below), not to
  811. comp.lang.c++.
  812.  
  813. Here are some other potentially relevant newsgroups:
  814.  * comp.lang.c++.moderated
  815.    - A moderated variant of comp.lang.c++
  816.    - The moderator's job is to keep the signal-to-noise ratio higher than in
  817.      comp.lang.c++
  818.  * comp.object
  819.    - Mostly OO design issues, with less emphasis on OO programming)
  820.    - That group's FAQ contains an excellent introduction to OO along with an
  821.      overview of OO terms and concepts
  822.  * comp.std.c++
  823.    - Discussion directly related to the evolving ANSI/ISO C++ standard
  824.    - The evolving ANSI/ISO C++ standard is discussed below
  825.  * comp.os.ms-windows.programmer.tools
  826.    - This group is intended for discussions about the selection and use of
  827.      tools for Windows software development
  828.  * comp.os.ms-windows.programmer.misc
  829.    - This group is for all other discussions about Windows software development
  830.    - There's one FAQ list for all the comp.os.ms-windows.programmer.* groups
  831.    - Sample topic: Accessing C++ classes in a DLL
  832.    - Sample topic: A dialog as an MDI child window [with OWL]
  833.    - Sample topic: Disabled menu choices become enabled [with MFC]
  834.    - Sample topic: Using STRICT with windows.h
  835.    - Sample topic: A programmer's bibliography
  836.  * comp.os.msdos.programmer
  837.    - Much of the traffic is about language products, chiefly from Borland and
  838.      Microsoft
  839.    - Note: The FAQ for this group is not available at rtfm.mit.edu; it is at
  840.      ftp://oak.oakland.edu/pub/msdos/info and ftp://garbo.uwasa.fi/pc/doc-net
  841.    - Sample topic: How can I read a character without [waiting for] the Enter
  842.      key?
  843.    - Sample topic: How can I read, create, change, or delete the volume label?
  844.    - Sample topic: How do I configure a COM port and use it to transmit data?
  845.    - Sample topic: How can a C program send control codes to my printer?
  846.    - Sample topic: How can I find the Microsoft mouse position and button
  847.      status?
  848.    - Sample topic: How can I write a TSR (terminate-stay-resident) utility?
  849.    - Sample topic: How can I contact [Borland, Microsoft]?
  850.  * comp.os.msdos.programmer.turbovision
  851.    - Borland's character-mode framework
  852.  * comp.unix.programmer
  853.    - Sample topic: How do I use popen() to open a process for reading and
  854.      writing?
  855.    - Sample topic: How do I sleep() in a C program for less than one second?
  856.  * comp.unix.solaris
  857.    - Covers SunOS 4.x and Solaris
  858.    - Sample topic: Signal Primer
  859.    - Sample topic: Waiting for Children to Exit
  860.  * gnu.g++.help
  861.    - Sample topic: Where can I find a demangler?
  862.    - Sample topic: Getting gcc/g++ binaries for Solaris 2.x
  863.    - Sample topic: What documentation exists for g++ 2.x?
  864.  * comp.sys.mac.programmer.* and comp.sys.mac.oop.*
  865.    - Macintosh issues
  866.  * gnu.g++.bug
  867.    - Bug reports for g++; see the g++ docs
  868.  * comp.lang.c
  869.    - FAQ is posted monthly, and is maintained by Steve Summit, scs@eskimo.com
  870.    - Sample topic: I'm confused.  NULL is guaranteed to be 0, but the null
  871.      pointer is not?
  872.    - Sample topic: So what is meant by the "equivalence of pointers and arrays"
  873.      in C?
  874.    - Sample topic: Why doesn't printf("%d\n", i++ * i++); work?
  875.    - Sample topic: How can I write a function that takes a variable number of
  876.      arguments? [stdarg.h or varargs.h]
  877.    - Sample topic: How do I declare an array of pointers to functions returning
  878.      pointers to functions returning pointers to characters?
  879.  * comp.graphics
  880.    - Issues revolving around graphics programming
  881.  * comp.sources.wanted
  882.    - If you want some source code for something, post your request there
  883.  * comp.programming
  884.    - General programming issues
  885.  
  886. ==============================================================================
  887.  
  888. [5.9] How do I get the FAQs for a particular newsgroup?
  889.  
  890. Let me count the ways...
  891.  
  892. FAQs (Frequently Asked Questions lists) are available 24-hours a day via:
  893.  * ftp or WWW: ftp://rtfm.mit.edu/pub/usenet/
  894.  * e-mail: send a message with the line "help" to mail-server@rtfm.mit.edu
  895.  * usenet: many FAQs are available in the newsgroup news.answers
  896.  
  897. Please, PLEASE do not send e-mail to me!
  898.  
  899. ==============================================================================
  900.  
  901. SECTION [6]: Big Picture issues
  902.  
  903.  
  904. [6.1] Is C++ a practical language?
  905.  
  906. Yes.
  907.  
  908. C++ is a practical tool.  It's not perfect[6.2], but it's useful.
  909.  
  910. In the world of industrial software, C++ is viewed as a solid, mature,
  911. mainstream tool.  It has widespread industry support which makes it "good" from
  912. an overall business perspective.
  913.  
  914. ==============================================================================
  915.  
  916. [6.2] Is C++ a perfect language?
  917.  
  918. Nope.
  919.  
  920. C++ wasn't designed to demonstrate what a perfect OO language looks like.  It
  921. was designed to be a practical tool for solving real world problems.  It has a
  922. few warts, but the only place where it's appropriate to keep fiddling with
  923. something until it's perfect is in a pure academic setting.  That wasn't C++'s
  924. goal.
  925.  
  926. ==============================================================================
  927.  
  928. [6.3] What's the big deal with OO?
  929.  
  930. Object-oriented techniques are the best way we know of to develop large,
  931. complex software applications and systems.
  932.  
  933. OO hype: the software industry is "failing" to meet demands for large, complex
  934. software systems.  But this "failure" is actually due to our successes: our
  935. successes have propelled users to ask for more.  Unfortunately we created a
  936. market hunger that the "structured" analysis, design and programming techniques
  937. couldn't satisfy.  This required us to create a better paradigm.
  938.  
  939. C++ is an OO programming language.  C++ can also be used as a traditional
  940. programming language (as "as a better C").  However if you use it "as a better
  941. C," don't expect to get the benefits of object-oriented programming.
  942.  
  943. ==============================================================================
  944.  
  945. [6.4] Is C++ better than Ada? (or Visual Basic, C, FORTRAN, Pascal, Smalltalk,
  946.       or any other language?)
  947.  
  948. This question generates much much more heat than light.  Please read the
  949. following before posting some variant of this question.
  950.  
  951. In 99% of the cases, programming language selection is dominated by business
  952. considerations, not by technical considerations.  Things that really end up
  953. mattering are things like availability of a programming environment for the
  954. development machine, availability of runtime environment(s) for the deployment
  955. machine(s), licensing/legal issues of the runtime and/or development
  956. environments, availability of trained developers, availability of consulting
  957. services, and corporate culture/politics.  These business considerations
  958. generally play a much greater role than compile time performance, runtime
  959. performance, static vs. dynamic typing, static vs. dynamic binding, etc.
  960.  
  961. Anyone who argues in favor of one language over another in a purely technical
  962. manner (i.e., who ignores the dominant business issues) exposes themself as a
  963. techie weenie, and deserves not to be heard.
  964.  
  965. ==============================================================================
  966.  
  967. [6.5] Who uses C++?
  968.  
  969. Lots and lots of companies and government sites.  Lots.
  970.  
  971. The number of C++ developers doubles every year.  You can imagine that five
  972. people are becomming C++ developers while you read this FAQ.
  973.  
  974. Growth is one of several critical features of C++[6.7].
  975.  
  976. ==============================================================================
  977.  
  978. [6.6] How long does it take to learn OO/C++?
  979.  
  980. Companies like Paradigm Shift, Inc. info@parashift.com successfully teach
  981. standard industry "short courses," where we compress a university semester
  982. course into one 40 hour work week.  But regardless of where you get your
  983. training, make sure the courses have a hands-on element, since most people
  984. learn best when they have projects to help the concepts "gel." But even if they
  985. have the best training, they're not ready yet.
  986.  
  987. It takes 6-12 months to become proficient in OO/C++.  Less if the developers
  988. have easy access to a "local" body of experts, more if there isn't a "good"
  989. general purpose C++ class library available.  To become one of these experts
  990. who can mentor others takes around 3 years.
  991.  
  992. Some people never make it.  You don't have a chance unless you are teachable
  993. and have personal drive.  As a bare minimum on "teachability," you have to be
  994. able to admit when you've are wrong.  As a bare minimum on "drive," you must be
  995. willing to put in some extra hours (it's a lot easier to learn some new facts
  996. than it is to change your paradigm [i.e., to change the way you think; to
  997. change your notion of goodness; to change your mental model of the world of
  998. technology]).
  999.  
  1000. Two things you should do:
  1001.  * Bring in a "mentor"[26.1]
  1002.  * Get your people two books: one to tell them what is legal[26.6], another to
  1003.    tell them what is moral[26.5]
  1004.  
  1005. Two things you should not do:
  1006.  * Don't bother having your people trained in C as a stepping-stone to learning
  1007.    OO/C++[26.2]
  1008.  * Don't bother having your people trained in Smalltalk as a stepping-stone to
  1009.    learning OO/C++[26.3]
  1010.  
  1011. ==============================================================================
  1012.  
  1013. [6.7] What are some features of C++ from a business perspective?
  1014.  
  1015. Here are a few features of OO/C++ from a business perspective:
  1016.  * C++ has a huge installed base[6.5], which means you'll have multi-vendor
  1017.    support for tools, environments, consulting services, etc.[6.4], plus you'll
  1018.    have a very valuable line-item on your resume
  1019.  * C++ lets developers provide simplified interfaces[7.3] to software chunks,
  1020.    which improves the defect-rate when those chunks are (re)used
  1021.  * C++ lets you exploit developer's intuition through operator
  1022.    overloading[13.2], which reduces the learning curve for (re)users
  1023.  * C++ localizes access[7.4] to a software chunk, which reduces the cost of
  1024.    changes.
  1025.  * C++ reduces the safety-vs.-usability tradeoff[7.5], which improves the cost
  1026.    of (re)using a chunk of software.
  1027.  * C++ reduces the safety-vs.-speed tradeoff[9.2], which improves defect rates
  1028.    without degrading performance.
  1029.  * C++ gives you inheritance and dynamic binding[6.8] which let old code call
  1030.    new code[6.9], making it possible to quickly extend/adapt your software to
  1031.    hit narrow market windows.
  1032.  
  1033. ==============================================================================
  1034.  
  1035. [6.8] Are virtual functions (dynamic binding) central to OO/C++?
  1036.  
  1037. Yes!
  1038.  
  1039. Without virtual functions[20], C++ is just a syntactic variant of C.  Operator
  1040. overloading[13] and non-virtual member functions are great, but they are, after
  1041. all, just syntactic sugar for the more typical C notion of passing a pointer to
  1042. a struct to a function.
  1043.  
  1044. From a business perspective, C++ without virtual functions has very little
  1045. value-add over straight C.  Technical people often think that there is a large
  1046. difference between C and non-OO C++, but without OO, difference usually isn't
  1047. enough to justify the cost of training developers, new tools, etc.  In other
  1048. words, if I were to advise a manager regarding whether to switch from C to
  1049. non-OO C++ (i.e., to switch languages but not paradigms), I'd probably
  1050. discourage him or her unless there were compelling tool-oriented reasons.  From
  1051. a business perspective, OO can help make systems extensible andadaptable, but
  1052. just the syntax of C++ classes without OO may not even reduce the maintenance
  1053. cost, and it surely adds to the training cost significantly.
  1054.  
  1055. Bottom line: C++ without virtual is not OO.  Programming with classes but
  1056. without dynamic binding is called "object based," but not "object oriented."
  1057. Throwing out virtual functions is the same as throwing out OO.  All you have
  1058. left is object-based programming, similar to the original Ada language (the new
  1059. Ada language, by the way, supports true OO rather than just object-based
  1060. programming).
  1061.  
  1062. ==============================================================================
  1063.  
  1064. [6.9] I'm from Missouri.  Can you give me a simple reason why virtual functions
  1065.       (dynamic binding) make a big difference?
  1066.  
  1067. Overview: Dynamic binding can improve reuse by letting old code call new code.
  1068.  
  1069. Before OO came along, reuse was accomplished by having new code call old code.
  1070. For example, a programmer might write some code that called some reusable code
  1071. such as printf().
  1072.  
  1073. With OO, reuse can also be accomplished by having old code call new code.  For
  1074. example, a programmer might write some code that is called by a framework that
  1075. was written by their great, great grandfather.  There's no need to change
  1076. great-great-grandpa's code.  In fact, it doesn't even need to be recompiled.
  1077. Even if all you have left is the object file and the source code that
  1078. great-great-grandpa wrote was lost 25 years ago, that ancient object file will
  1079. call the new extension without anything falling apart.
  1080.  
  1081. That is extensibility, and that is OO.
  1082.  
  1083. ==============================================================================
  1084.  
  1085. [6.10] Is C++ backward compatible with ANSI/ISO-C?
  1086.  
  1087. Almost.
  1088.  
  1089. C++ is as close as possible to compatible with C, but no closer.  In practice,
  1090. the major difference is that C++ requires prototypes, and that f() declares a
  1091. function that takes no parameters (in C, f() is the same as f(...)).
  1092.  
  1093. There are some very subtle differences as well, like sizeof('x') is equal to
  1094. sizeof(char) in C++ but is equal to sizeof(int) in C.  Also, C++ puts structure
  1095. "tags" in the same namespace as other names, whereas C requires an explicit
  1096. struct (e.g., the typedef struct Fred Fred; technique still works, but is
  1097. redundant in C++).
  1098.  
  1099. ==============================================================================
  1100.  
  1101. [6.11] Are there any C++ standardization efforts underway?
  1102.  
  1103. Yes; ANSI (American) and ISO (International) groups are working closely with
  1104. each other.  The ANSI-C++ committee is called "X3J16".  The ISO C++ standards
  1105. group is called "WG21".  The major players in the ANSI/ISO C++ standards
  1106. process includes just about everyone:
  1107.  
  1108. AT&T, IBM, DEC, HP, Sun, MS, Borland, Zortech, Apple, OSF, etc ad nauseum.
  1109. Dozens of people attend each meeting.  People come from USA, UK, Japan,
  1110. Germany, Sweden, Denmark, France, ... (all have "local" committees sending
  1111. official representatives and conducting "local" meetings).
  1112.  
  1113. ==============================================================================
  1114.  
  1115. [6.12] Where can I get a copy of the latest ANSI/ISO-C++ draft standard?
  1116.  
  1117. The ISO Committee Draft for C++ and the ANSI C++ Draft (the document that is
  1118. going out for public review) is available from:
  1119.  * http://www.cygnus.com/~mrs/wp-draft
  1120.  
  1121. You can also get Postscript and Adobe Acrobat versions from:
  1122.  * ftp://research.att.com/dist/c++std/WP
  1123.  * ftp://ftp.maths.warwick.ac.uk:/pub/c++/std/WP
  1124.  * ftp://ftpt.su.edu.au:/pub/C++/CommitteeDraft
  1125.  
  1126. You can get HTML and ASCII versions:
  1127.  * ftp://ftp.cygnus.com/pub/g++
  1128.  
  1129. You can also get a paper copy from:
  1130.  * Lynn Barra <lbarra@itic.nw.dc.us>
  1131.  * Ask for the latest version of "Draft Proposed American National Standard for
  1132.    Information Systems -- Programming Language C++" which is document number
  1133.    CD14882
  1134.  * It is typically shipped 2-day FedEx within the continental US
  1135.  
  1136. You can also order a paper copy via snail-mail:
  1137.  * X3 Secretariat
  1138.    1250 Eye Street NW
  1139.    Suite 200
  1140.    Washington, DC 20005
  1141.    202-626-5738
  1142.  * Ask for the latest version of "Draft Proposed American National Standard for
  1143.    Information Systems -- Programming Language C++" which is document number
  1144.    CD14882
  1145.  * It is typically shipped 2-day FedEx within the continental US
  1146.  
  1147. ==============================================================================
  1148.  
  1149.